<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {

    public function index(){
        // $Model = M();
        // $sql = "SELECT * FROM `test`";
        // $data = $Model->query($sql);
        // var_dump($data);
        // $this->ajaxReturn(json_encode($data), 'JSON');
        // $this->assign('data', $data);
        // $this->redirect('index');
        // $this->redirect('carking');
        // $Model = M();
        // $sql = "SELECT * FROM `message` order by id desc";
        // $data = $Model->query($sql);
        // // $this->ajaxReturn(json_encode($data), 'JSON');
        // $this->assign('data', $data);
        // $this->redirect('indexs');
        $this->display();
    }
    public function anli(){
        $this->display('anli');
    }
    public function liuyan(){
        $Model = M();
        $sql = "SELECT * FROM `message` where flag = '0' order by id desc limit 0,20";
        $data = $Model->query($sql);
        // $this->ajaxReturn(json_encode($data), 'JSON');
        $this->assign('data', $data);
        $this->display('liuyan');
    }
    public function addly(){
        if (IS_POST) {
            $Model = M();
            if($_POST['note'] ){
                $sql = "INSERT INTO `message` (note,cip,create_time,updata_time) VALUES ('".$_POST['note']."','".$_POST['ip']."',now(),now())";
                $Model->execute($sql);
            }
            $this->ajaxReturn(['success' => true]);
            // }
            // else {
            // $this->ajaxReturn(['success' => false, 'content' => $jsonArrayData['description']]);
            // }
            // $this->display();
            // $this->redirect('/Home/Index/liuyan');
        }
    }
}